package com.bff.gaia.streaming.api.mo.gaia.api;

import com.bff.gaia.streaming.api.mo.gaia.cache.TopkStack;

import java.io.Serializable;

public class ElectoralMechanism implements Serializable {

	private boolean flag = true;
	private TopkStack stack = null;
	private int N;
	private String address = null;
	private int port;
	private String name;
	private Double currentFilter = null;
	private boolean reported = false;

	public ElectoralMechanism(boolean flag, int N, String address, int port, String name, Double currentFilter) {
		this.flag = flag;
		this.N = N;
		this.address = address;
		this.port = port;
		this.name = name;
		this.currentFilter = currentFilter;
	}

	public void sendData() {
		if (this.flag) {
			this.stack = new TopkStack(this.N);
			this.flag = false;
			Double empty = null;
			Client c = new Client(this.address, this.port, this.name, empty);
			c.connect();
			this.currentFilter = c.getMin();
		}
	}
}